package com.didispace.controller;

import com.didispace.domain.TestMesg;
import com.didispace.domain.User;
import com.didispace.service.TestMesgService;
import com.didispace.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("jdbc")
public class JdbcTestController {

    @Autowired
    private UserService userService;

    @Autowired
    private TestMesgService testMesgService;

    @RequestMapping("/users")
    public void postUser(@ModelAttribute User user){
        userService.createByJdbc(user.getName(),user.getAge());
    }

    @RequestMapping("/mesgs")
    public void postMesg(@ModelAttribute TestMesg mesg){
        testMesgService.createMsgByJdbc(mesg.getTitle(),mesg.getMessage());
    }
}
